package com.qn.utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @since 2020/10/2 23:33   @author 老周  @version 1.00
 * Description Jedis工具
 */
public class JedisUtils {
    //创建连接池
    private static JedisPoolConfig config;
    private static JedisPool pool;

    static{
        config=new JedisPoolConfig();
        config.setMaxTotal(30);
        config.setMaxIdle(2);

        pool=new JedisPool(config, "47.92.135.154", 6379);
    }


    //获取连接的方法
    public static Jedis getJedis(){
        return pool.getResource();
    }


    //释放连接
    public static void closeJedis(Jedis j){
        j.close();
    }
}
